package com.hyj.boxueguxiangmu.activity;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hyj.boxueguxiangmu.R;
import com.hyj.boxueguxiangmu.fragment.CourseFragment;
import com.hyj.boxueguxiangmu.fragment.ExerciseFragment;
import com.hyj.boxueguxiangmu.fragment.MyFragment;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

    FragmentManager fragmentManager;
    FragmentTransaction fragmentTransaction;
    ImageView curseImg;
    ImageView exerciseImg;
    ImageView myImg;
    TextView curseTv;
    TextView exerciseTv;
    TextView myTv;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        curseImg = (ImageView) findViewById(R.id.course_img);
        exerciseImg = (ImageView) findViewById(R.id.exercise_img);
        myImg = (ImageView) findViewById(R.id.my_img);
        curseTv = (TextView) findViewById(R.id.curseTv);
        exerciseTv = (TextView) findViewById(R.id.exerciseTv);
        myTv = (TextView) findViewById(R.id.myTv);

        fragmentManager = getFragmentManager();
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();
    }
    public void  course(View view){
        curseImg.setImageResource(R.drawable.main_course_icon_selected);
        curseTv.setTextColor(Color.parseColor("#219AEF"));
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();
    }
    public void  exercise(View view){
        exerciseImg.setImageResource(R.drawable.main_exercises_icon_selected);
        exerciseTv.setTextColor(Color.parseColor("#219AEF"));
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new ExerciseFragment());
        fragmentTransaction.commit();
    }
    public void  my(View view){
        myImg.setImageResource(R.drawable.main_my_icon_selected);
        myTv.setTextColor(Color.parseColor("#219AEF"));
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new MyFragment());
        fragmentTransaction.commit();
    }
}
